﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace TileEditor
{

    public struct Entity
    {
        int x;

        public int X
        {
            get { return x; }
            set { x = value; }
        }

        int y;

        public int Y
        {
            get { return y; }
            set { y = value; }
        }

        int type;

        public int Type
        {
            get { return type; }
            set { type = value; }
        }


        int group;

        public int Group
        {
            get { return group; }
            set { group = value; }
        }

        string name;

        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        
        public Entity(string n = "Default")
        {
            name = n;
            group = -1;
            type = -1;
            x = -1;
            y = -1;


        }
        public Entity(int type, string name)
        {
            x = -1;
            y = -1;
            this.type = type;
            group = -1;
            this.name = name;
        }

        public override string ToString()
        {
            return name.ToString();
        }
    }

    public struct Level
    {

        public Level(int numLayers, int numTileSets, int numGroups, int mapW, int mapH,
                      int tileW, int tileH)
        {
            currLayer = new int();
            currLayer = 0;

            currTileSet = new int();
            currTileSet = 0;

            layers = new Layer[numLayers];
            for (int i = 0; i < numLayers; i++)
            {
                layers[i] = new Layer(mapW, mapH);
                for (int w = 0; w < mapW; w++)
                {
                    for (int h = 0; h < mapH; h++)
                    {
                        layers[i].Map[w, h] = new Tile();
                        layers[i].Map[w, h].TileID = -1;
                        layers[i].Map[w, h].X = w * tileW;
                        layers[i].Map[w, h].Y = h * tileH;
                        layers[i].Map[w, h].SetID = -1;
                        layers[i].Map[w, h].TriggerGroup = -1;
                    }
                }
            }
            tileSets = new TileSet[numTileSets];
            for (int i = 0; i < numTileSets; i++)
            {
                tileSets[i].Id = -1;
                tileSets[i].Path = "-1";
            }
            groups = new TriggerGroup[numGroups];

            mapSize = new Size();
            mapSize.Width = mapW;
            mapSize.Height = mapH;

            tileSize = new Size();
            tileSize.Width = tileW;
            tileSize.Height = tileH;

            playerSpawn = new Point();
            playerSpawn.X = -1;
            playerSpawn.Y = -1;
        }

        Point playerSpawn;

        public Point PlayerSpawn
        {
            get { return playerSpawn; }
            set { playerSpawn = value; }
        }


        // This is the multiple layers of maps
        Layer[] layers;

        public Layer[] Layers
        {
            get { return layers; }
            set { layers = value; }
        }

        Size mapSize;

        public Size MapSize
        {
            get { return mapSize; }
            set { mapSize = value; }
        }

        Size tileSize;

        public Size TileSize
        {
            get { return tileSize; }
            set { tileSize = value; }
        }



        TileSet[] tileSets;

        public TileSet[] TileSets
        {
            get { return tileSets; }
            set { tileSets = value; }
        }

        TriggerGroup[] groups;

        public TriggerGroup[] Groups
        {
            get { return groups; }
            set { groups = value; }
        }

        int currLayer;

        public int CurrLayer
        {
            get { return currLayer; }
            set { currLayer = value; }
        }

        int currTileSet;

        public int CurrTileSet
        {
            get { return currTileSet; }
            set { currTileSet = value; }
        }
    }
}
